<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
        
        <h3>Thêm mới nhóm sản phẩm</h3>
        
        <ul class="content-box-tabs">
       
            <li><a href="#">Table</a></li> <!-- href must be unique and match the id of target div -->
            <li><a href="#tab2" class="default-tab">Forms</a></li>
        </ul>
        
        <div class="clear"></div>
        
    </div> <!-- End .content-box-header -->
    
    <div class="content-box-content">
   		
        

        <div class="content-box-tabs" id="tab2">
    <?php
	$txt_tendanhmuc='';$txt_madanhmuc='';$txt_anhdm='';$txt_machungloai='';
	$hide_show=1;
	
	if(isset($_POST['txt_madanhmuc']))			{$txt_madanhmuc=$_POST['txt_madanhmuc']; $hide_show=0;}
	if(isset($_POST['txt_tendanhmuc']))		$txt_tendanhmuc=$_POST['txt_tendanhmuc'];
	
	if($hide_show==1)
	{
	?>
    <form action="" method="post" enctype="multipart/form-data">
        
        <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
            <p>
                <label for="txt_anhdm">Ảnh danh mục</label>
                <input type="file" name="txt_anhdm" id="txt_anhdm" />
            </p>
            <p>
                <label for="txt_tendanhmuc">Tên danh mục</label>
            	<input type="text" name="txt_tendanhmuc" id="txt_tendanhmuc" style="width:400px;"/>
            </p>
            
            <p>
                <label for="txt_madanhmuc">Mã danh mục </label>
            	<input name="txt_madanhmuc" id="madm" style="width:405px;" >

            </p>
            
            <p>
                <input class="button" type="submit" value="Submit" name="add"/>
                <input type="reset" value="Nhập lại" name="btn_reset"/>
            </p>
            
        </fieldset>
        
        <div class="clear"></div><!-- End .clear -->
        
    </form>
    <?php
	}
	else
	{
        //Define some variables
        $dir = "uploads/"; //Bạn nên thay đổi đường dẫn cho phù hợp
        //Kiều file, Gif, jpeg, zip ::bạn có thể sửa đổi nếu thích
        $types = array("image/gif","image/GIF","image/JPG","image/PNG","image/png","image/jpg","image/JPEG","image/jpeg","application/x-zip-compressed","application/msword","application/vnd.ms-excel");
        //Check to determine if the submit button has been pressed
        if(isset($_POST["add"])){
            //Shorten Variables
            $tmp_name = $_FILES["txt_anhdm"]["tmp_name"];
            $new_name = $_FILES["txt_anhdm"]["name"];
            //Check MIME Type
            if (in_array($_FILES["txt_anhdm"]["type"], $types)){
                //Move file from tmp dir to new location
                move_uploaded_file($tmp_name,'../'.$dir.$new_name);
                $txt_anhdm=$new_name;
                echo "<script>alert('File {$_FILES["txt_anhdm"]["name"]} đã gửi xong!');</script>";
            }else{
                //Print Error Message
                echo "<script>alert('{$_FILES["txt_anhdm"]["name"]} upload file thất bại !');</script>";
                //Debug
                $name =  $_FILES["txt_anhdm"]["name"];
                $type =  $_FILES["txt_anhdm"]["type"];
                $size =  $_FILES["txt_anhdm"]["size"];
                $tmp  =  $_FILES["txt_anhdm"]["name"];
                echo "Name: $name<br/ >Type: $type<br />Size: $size<br />Tmp: $tmp";
            }
        }
        else{
            echo 'Không có file upload';
        }
		//Xu ly them du lieu
		//Tao cau lenh SQL
		
		$sql="	INSERT INTO tbl_danhmuc(danhmuc,anhdm,danhmuc_id) VALUES('".$txt_tendanhmuc."','".$txt_anhdm."','".$txt_madanhmuc."')";
		
		//Thuc thi cau lenh SQL
		$result=mysql_query($sql);
		echo '<p style="color:#F06">Thêm danh mục thành công</p>';
		//Chuyen trang ve danh muc san pham
		header('refresh:1; index.php?page=danhmuc');
		}
	
?>
        </div> <!-- End #tab2 -->
        
              
		<div class="tab-content" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
        
        </div> <!-- End #tab1 -->
    </div> <!-- End .content-box-content -->
    
</div> <!-- End .content-box -->